<?php
/**
 * @Copyright   2008, XXXX-XXXX
 * All rights reserved. 
 * feature summary.
 * @filesource  DostuffCommand.php 
 * @author      lipeng <lipengage@gmain.com> 
 * @package     / 
 * @version     $Id: $ 
 */

class DostuffCommand extends command{
	public $actor;
	public $target;
	public $container;
	public $userdb;
	public $activitydb;

	public function get_player() {
		$this->container = $container = $this->request["ctn"];
		$actorid = $this->request["vid"];
		$targetid = $this->request["targetid"];
		if (empty($actorid) || empty($targetid) || empty($container)) {
			$this->set_messageid(command::$PARAM_ERROR);
			return true;
		}
		$this->userdb = new user_dao();
		$this->activitydb = new activity_dao();

		$this->actor = $this->userdb->user_get_byid($container, $actorid);
		$this->target = $this->userdb->user_get_byid($container, $targetid);
		
		if (($this->actor["count"] < 1) || ($this->target["count"] < 1)) {
			$this->set_messageid(command::$PARAM_ERROR);
			return true;
		}
		else {
			$this->actor = $this->actor["result"][0];
			$this->target = $this->target["result"][0];
		}
		return false;
	}

	public function is_slave() {
		if ($this->target["master_id"] == $this->actor["uid"]) {
			return 1;
		}
		if ($this->actor["master_id"] == $this->target["uid"]) {
			return -1;
		}
		$this->set_messageid(command::$NOT_YOUR_SLAVE);
		return true;
	}
	
	public function check_cmd_catalog($key) {
		if (empty($this->catalog[$key])) {
			$this->set_messageid(command::$PARAM_ERROR);
			return true;
		}
		return false;
	}

	public function get_cmd_catalog($key) {
		return $this->catalog[$key];
	}

	public function set_cmd_catalog($key,$value) {
		$this->catalog[$key] = $value;
	}

	public function new_activity($type) {
		$activity = array();
		$activity["container"] = $this->container;
		$activity["actor"] = $this->actor["uid"];
		$activity["actor_name"] = $this->actor["name"];
		$activity["target"] = $this->target["uid"];
		$activity["target_name"] = $this->target["name"];
		$activity["time"] = time();
		$activity["type"] = $type;
		$activity["command"] = $this->get_cmd_catalog("messageId");
		return $activity;
	}
	
	public function excute() {
	}
}
?>